package cn.com.wxd.util.website;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.com.wxd.common.CharUtil;
import cn.com.wxd.util.action.AccessLogUtil;

/**
 * Title:WebsiteInfo.java
 * Description:cn.com.wxd.util.service
 * <p>
 * Company: Amumu管理平台
 * Copyright: Copyright (c) 2015
 * All right reserved.
 * Created time: 2015-12-14 下午12:22:11
 *
 * @author WangXuDong
 * @version 1.0
 */
public class WebsiteInfo implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = -3189816840035522038L;
    private static final Logger log = LoggerFactory.getLogger(WebsiteInfo.class);

    private static String websiteName;
    private static String articleIndexPath;
    private static String registInfo;
    private static String description;
    private static String phone;
    private static String email;
    private static String weiXin;
    private static String qQ;
    private static String weiBo;
    private static boolean Cache;
    private static int cacheMaxCount;
    private static String rssLevel3Page;

    static {
        init();
    }

    public static void init() {
        Properties prop = new Properties();
        try {
            InputStream inputStream = WebsiteInfo.class.getResourceAsStream("/wxd.website.properties");
            BufferedReader bf = new BufferedReader(new InputStreamReader(inputStream));
            prop.load(bf);

            websiteName = prop.getProperty("Name");
            registInfo = prop.getProperty("RegistInfo");
            description = prop.getProperty("Description");
            phone = prop.getProperty("Phone");
            qQ = prop.getProperty("QQ").trim();
            weiXin = prop.getProperty("WeiXin");
            email = prop.getProperty("Email");
            weiBo = prop.getProperty("WeiBo");
            rssLevel3Page = prop.getProperty("RssLevel3Page");
            Cache = Boolean.parseBoolean(prop.getProperty("IsCache"));
            cacheMaxCount = CharUtil.stringParsInt(prop.getProperty("CacheMaxCount"));
            articleIndexPath = prop.getProperty("ArticleIndexPath");

        } catch (Exception e) {
            log.error("website.properties项目配置文件读取错误" + e.getMessage(), e);
        }
    }

    public static String getWebsiteName() {
        return websiteName;
    }

    public static String getArticleIndexPath() {
        return articleIndexPath;
    }

    public static String getRegistInfo() {
        return registInfo;
    }

    public static String getDescription() {
        return description;
    }

    public static String getPhone() {
        return phone;
    }

    public static String getEmail() {
        return email;
    }

    public static String getWeiXin() {
        return weiXin;
    }

    public static String getQQ() {
        return qQ;
    }

    public static String getWeiBo() {
        return weiBo;
    }

    public static boolean isCache() {
        return Cache;
    }

    public static int getCacheMaxCount() {
        return cacheMaxCount;
    }

    /**
     * 获取在线人数
     *
     * @return
     */
    public static int getOnlineUser() {
        return AccessLogUtil.getOnlineUser();
    }

    /**
     * 获取总访问量
     *
     * @return
     */
    public static int getTatorAccessVolume() {
        return AccessLogUtil.getTatorAccessVolume();
    }

    public static String getRssLevel3Page() {
        return rssLevel3Page;
    }

    public static void setRssLevel3Page(String rssLevel3Page) {
        WebsiteInfo.rssLevel3Page = rssLevel3Page;
    }

}

